package shuashuami.hb.com.avtivity;

import android.app.Dialog;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

import shuashuami.hb.com.Application;
import shuashuami.hb.com.hbclient.R;
import shuashuami.hb.com.hdlibrary.glid.GlidUtil;
import shuashuami.hb.com.view.ZoomImageView;

public class BigImagesActivity extends AbActivity {
    private ViewPager mViewPager;
    private List<String> images;
    private ImageView[] mImageViews;

    private GlidUtil glidUtil;

    private Dialog dialog;

    @Override
    protected void initUI() {
        setAbContentView(R.layout.activity_big_images);
        mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
        setLeftView();
    }

    Application application;

    @Override
    protected void initData() {
        setTitleBar("图片浏览");
        glidUtil = new GlidUtil(this);
        application = (Application) getApplication();
        images = application.getImages();
        mImageViews = new ImageView[images.size()];
        mViewPager.setAdapter(new PagerAdapter() {

            @Override
            public Object instantiateItem(ViewGroup container, int position) {
                final ZoomImageView imageView = new ZoomImageView(
                        getApplicationContext());
                glidUtil.uploadImage(images.get(position), R.mipmap.app_logo, imageView);
                container.addView(imageView);
                mImageViews[position] = imageView;
                return imageView;
            }

            @Override
            public void destroyItem(ViewGroup container, int position,
                                    Object object) {
                container.removeView(mImageViews[position]);
            }

            @Override
            public boolean isViewFromObject(View arg0, Object arg1) {
                return arg0 == arg1;
            }

            @Override
            public int getCount() {
                return images.size();
            }
        });
    }

    @Override
    protected void initListener() {
        setLeftViewListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }



}
